<html><head>
  <title>:nth-child() pseudo-class</title>
  <style type="text/css">.green { background-color : lime ! important }
ul > li:nth-child(odd) { background-color : red }
ol > li:nth-child(even) { background-color : red }
table.t1 tr:nth-child(-n+4) { background-color : red }
table.t2 td:nth-child(3n+1) { background-color : red }</style>
  <link rel="author" title="Daniel Glazman" href="http://glazman.org/">
  <link rel="author" title="Ian Hickson" href="mailto:ian@hixie.ch">
  <link rel="help" href="https://www.w3.org/TR/css3-selectors/#selectors"> <!-- bogus link to make sure it gets found -->
  <meta name="flags" content="">
 </head>
 <body>
<ul>
  <!--[ELEMENT('.green')]--><li class="green"><!--[TEXT('.green')]-->This first list item should have a green background<!--[/TEXT('.green')]--></li><!--[/ELEMENT('.green')]-->
  <li>Second list item</li>
  <!--[ELEMENT('.green')]--><li class="green"><!--[TEXT('.green')]-->This third list item should have a green background<!--[/TEXT('.green')]--></li><!--[/ELEMENT('.green')]-->
  <li>Fourth list item</li>
  <!--[ELEMENT('.green')]--><li class="green"><!--[TEXT('.green')]-->This fifth list item should have a green background<!--[/TEXT('.green')]--></li><!--[/ELEMENT('.green')]-->
  <li>Sixth list item</li>
</ul>
<ol>
  <li>First list item</li>
  <!--[ELEMENT('.green')]--><li class="green"><!--[TEXT('.green')]-->This second list item should have a green background<!--[/TEXT('.green')]--></li><!--[/ELEMENT('.green')]-->
  <li>Third list item</li>
  <!--[ELEMENT('.green')]--><li class="green"><!--[TEXT('.green')]-->This fourth list item should have a green background<!--[/TEXT('.green')]--></li><!--[/ELEMENT('.green')]-->
  <li>Fifth list item</li>
  <!--[ELEMENT('.green')]--><li class="green"><!--[TEXT('.green')]-->This sixth list item should have a green background<!--[/TEXT('.green')]--></li><!--[/ELEMENT('.green')]-->
</ol>
<div>
<table border="1" class="t1">
  <tbody><!--[ELEMENT('.green')]--><tr class="green"><!--[TEXT('.green')]-->
<!--[/TEXT('.green')]--><td><!--[TEXT('.green')]-->Green row : 1.1<!--[/TEXT('.green')]--></td><!--[TEXT('.green')]-->
<!--[/TEXT('.green')]--><td><!--[TEXT('.green')]-->1.2<!--[/TEXT('.green')]--></td><!--[TEXT('.green')]-->
     <!--[/TEXT('.green')]--><td><!--[TEXT('.green')]-->1.3<!--[/TEXT('.green')]--></td><!--[TEXT('.green')]-->
<!--[/TEXT('.green')]--></tr><!--[/ELEMENT('.green')]-->
  <!--[ELEMENT('.green')]--><tr class="green"><!--[TEXT('.green')]-->
<!--[/TEXT('.green')]--><td><!--[TEXT('.green')]-->Green row : 2.1<!--[/TEXT('.green')]--></td><!--[TEXT('.green')]-->
<!--[/TEXT('.green')]--><td><!--[TEXT('.green')]-->2.2<!--[/TEXT('.green')]--></td><!--[TEXT('.green')]-->
     <!--[/TEXT('.green')]--><td><!--[TEXT('.green')]-->2.3<!--[/TEXT('.green')]--></td><!--[TEXT('.green')]-->
<!--[/TEXT('.green')]--></tr><!--[/ELEMENT('.green')]-->
  <!--[ELEMENT('.green')]--><tr class="green"><!--[TEXT('.green')]-->
<!--[/TEXT('.green')]--><td><!--[TEXT('.green')]-->Green row : 3.1<!--[/TEXT('.green')]--></td><!--[TEXT('.green')]-->
<!--[/TEXT('.green')]--><td><!--[TEXT('.green')]-->3.2<!--[/TEXT('.green')]--></td><!--[TEXT('.green')]-->
     <!--[/TEXT('.green')]--><td><!--[TEXT('.green')]-->3.3<!--[/TEXT('.green')]--></td><!--[TEXT('.green')]-->
<!--[/TEXT('.green')]--></tr><!--[/ELEMENT('.green')]-->
  <!--[ELEMENT('.green')]--><tr class="green"><!--[TEXT('.green')]-->
<!--[/TEXT('.green')]--><td><!--[TEXT('.green')]-->Green row : 4.1<!--[/TEXT('.green')]--></td><!--[TEXT('.green')]-->
<!--[/TEXT('.green')]--><td><!--[TEXT('.green')]-->4.2<!--[/TEXT('.green')]--></td><!--[TEXT('.green')]-->
      <!--[/TEXT('.green')]--><td><!--[TEXT('.green')]-->4.3<!--[/TEXT('.green')]--></td><!--[TEXT('.green')]-->
<!--[/TEXT('.green')]--></tr><!--[/ELEMENT('.green')]-->
  <tr>
<td>5.1</td>
<td>5.2</td>
<td>5.3</td>
</tr>
  <tr>
<td>6.1</td>
<td>6.2</td>
<td>6.3</td>
</tr>
</tbody></table>
<p></p>
<table class="t2" border="1">
  <tbody><tr>
<!--[ELEMENT('.green')]--><td class="green"><!--[TEXT('.green')]-->green cell<!--[/TEXT('.green')]--></td><!--[/ELEMENT('.green')]-->
<td>1.2</td>
<td>1.3</td>
      <!--[ELEMENT('.green')]--><td class="green"><!--[TEXT('.green')]-->green cell<!--[/TEXT('.green')]--></td><!--[/ELEMENT('.green')]-->
<td>1.5</td>
<td>1.6</td>
      <!--[ELEMENT('.green')]--><td class="green"><!--[TEXT('.green')]-->green cell<!--[/TEXT('.green')]--></td><!--[/ELEMENT('.green')]-->
<td>1.8</td>
</tr>
  <tr>
<!--[ELEMENT('.green')]--><td class="green"><!--[TEXT('.green')]-->green cell<!--[/TEXT('.green')]--></td><!--[/ELEMENT('.green')]-->
<td>2.2</td>
<td>2.3</td>
      <!--[ELEMENT('.green')]--><td class="green"><!--[TEXT('.green')]-->green cell<!--[/TEXT('.green')]--></td><!--[/ELEMENT('.green')]-->
<td>2.5</td>
<td>2.6</td>
      <!--[ELEMENT('.green')]--><td class="green"><!--[TEXT('.green')]-->green cell<!--[/TEXT('.green')]--></td><!--[/ELEMENT('.green')]-->
<td>2.8</td>
</tr>
  <tr>
<!--[ELEMENT('.green')]--><td class="green"><!--[TEXT('.green')]-->green cell<!--[/TEXT('.green')]--></td><!--[/ELEMENT('.green')]-->
<td>3.2</td>
<td>3.3</td>
      <!--[ELEMENT('.green')]--><td class="green"><!--[TEXT('.green')]-->green cell<!--[/TEXT('.green')]--></td><!--[/ELEMENT('.green')]-->
<td>3.5</td>
<td>3.6</td>
      <!--[ELEMENT('.green')]--><td class="green"><!--[TEXT('.green')]-->green cell<!--[/TEXT('.green')]--></td><!--[/ELEMENT('.green')]-->
<td>3.8</td>
</tr>
</tbody></table>
</div>

</body></html>